package com.wyh.controller.g3controller;

import com.wyh.common.enums.ResultCodeEnum;
import com.wyh.common.result.Result;
import com.wyh.domain.dto.g3dto.BuildingEstateArrearsDto;
import com.wyh.domain.vo.g3vo.BuildEstateArrearsVO;
import com.wyh.domain.vo.g3vo.BuildingProjectVO;
import com.wyh.service.g3service.IBuildingProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("/arrearsBuilding")
@Api(tags = "欠费楼盘查询")
public class ArrearsBuildingController {
    @Autowired
    private IBuildingProjectService buildingProjectService;

    @ApiOperation("查询所有楼盘以及园区")
    @GetMapping("/selectAll")
    public Result<BuildingProjectVO> selectAll() {
        BuildingProjectVO buildingProjectVO = buildingProjectService.selectBuildingProject();
        return Result.success(buildingProjectVO);
    }

    @ApiOperation("查询指定楼盘的欠款情况")
    @PostMapping("/selectArrears")
    public Result<BuildEstateArrearsVO> selectArrears(@ApiParam("查询楼盘的条件")@RequestBody BuildingEstateArrearsDto buildingEstateArrearsDto) {
        if (buildingEstateArrearsDto == null){
            return Result.error(ResultCodeEnum.PARAM_LOST_ERROR);
        }
        BuildEstateArrearsVO buildEstateArrearsVO = buildingProjectService.selectArrears(buildingEstateArrearsDto);
        if (buildEstateArrearsVO == null) {
            return Result.error(ResultCodeEnum.SYSTEM_ERROR);
        }
        return Result.success(buildEstateArrearsVO);
    }
    @ApiOperation("导出excel")
    @GetMapping("/export/arrearsBuilding")
    public void exportArrearsBuilding(HttpServletResponse response) {
            //调用导出方法
            buildingProjectService.exportArrearsBuilding(response);
    }


}
